Component({
  data: {
    active: 0
  },
  methods: {
    onChange(event) {
      // event.detail 的值为当前选中项的索引
      var active = event.detail;
      if (this.data.active == active) {
        return;
      }
      this.setData({
        active
      });
      var url = "";
      switch (active) {
        case 0 : url = "../../pages/index/index"; break;
        case 1 : url = "../../pages/search/index"; break;
        case 2 : url = "../../pages/friends/index"; break;
        case 3 : url = "../../pages/personal/index"; break;
      }
      console.log("url = " + url);
      wx.switchTab({
        url: url,
        fail(err) {
          // console.log(err);
        }
      }
      )
    },
  }
})